package com.soft.service;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

import com.soft.entity.User;

@SpringBootTest
public class UserServiceTest {
    @Autowired
	private UserService userService;
    @Test
    public void queryAllTest() {
    	List<User>userList = userService.queryAll();
    	Assert.notEmpty(userList,"为空");
    	Assert.isTrue(userList.size()>3, "数据小于3条");
    }
    //@Test
    public void queryByUserAgeTest() {
    	List<User> userList = userService.queryByUserAge("18");
    	Assert.isTrue(userList.size()==4, "根据age进行查询结果的数据不对");
    }
    //@Test
    public void insertOneTest() {
    	int num = userService.insertOne("荣赵晗", "30", "20060205@111.com");
    	Assert.isTrue(num == 1,"增加数据错误");
    }
    //@Test
    public void deleteByIdTest() {
    	int num = userService.deleteById(2l);
    	Assert.isTrue(num == 1, "删除数据错误");
    }
    //@Test
    public void update() {
    	int num = userService.update(3l,"jz", "10", "2442455@154.com");
    	Assert.isTrue(num == 1,"修改数据错误");
    }
    @Test
    public void queryByUserNameTest() {
    	List<User> userList = userService.queryByUserAge("18");
    	Assert.isTrue(userList.size()==2,"根据年龄进行查询结果不对");
    }
}
